package cn.dansj.handler.interfaces;

import cn.dansj.annotation.MarkAsApi;
import cn.dansj.enums.GlobalEnv;
import cn.dansj.common.utils.transfer.Transformation;
import cn.dansj.handler.InterfaceHandler;
import cn.dansj.utils.interfaces.InterfaceUtils;

import java.util.HashMap;
import java.util.Map;

@SuppressWarnings("all")
@MarkAsApi
public class InterfaceRunInfo extends InterfaceHandler {
    @Override
    public Object execute(Map<String, Object> paramsMap) {
        try {
            int total = Transformation.parseInt(jdbcTemplate.queryForMap("select count(1) num from x_interface_info where status=1 and api_type = 0").get("num"));
            Map<String, Integer> runInfo = new HashMap<>();
            runInfo.put("totalApi", total);
            runInfo.put("interfaceTotalCount", Transformation.parseInt(redisUtils.getString(GlobalEnv.InterfaceTotalCountPrefix)));
            return runInfo;
        } catch (Exception e) {
            InterfaceUtils.logger.error(e.getMessage(), e);
            return new HashMap<>();
        }
    }
}